package com.itboye.shop.presenter;

import com.itboye.shop.interfaces.YuEInterfaces;
import com.itboye.shop.net.ICompleteListener;
import com.itboye.shop.net.ResultEntity;
import com.itboye.shop.responsitory.YuEPresponsitory;

import java.util.Observer;

/**
 * 余额
 */
public class YuEPresenter extends BasePresenter implements YuEInterfaces<String> {

    /**
     * 设置支付密码
     */
    public static final String zhifu_pass_success = YuEPresenter.class.getName()
            + "_zhifu_pass_success";
    public static final String zhifu_pass_fail = YuEPresenter.class.getName()
            + "_zhifu_pass_fail";
    /**
     * 支付密码验证
     */
    public static final String yanzheng_pass_success = YuEPresenter.class.getName()
            + "_yanzheng_pass_success";
    public static final String yanzheng_pass_fail = YuEPresenter.class.getName()
            + "_yanzheng_pass_fail";
    /**
     * 余额
     */
    public static final String Yue_success = YuEPresenter.class.getName()
            + "_Yue_success";
    public static final String Yue_fail = YuEPresenter.class.getName()
            + "_Yue_fail";

    //充值（获取充值信息）
    public static final String chongzhi_success = YuEPresenter.class.getName()
            + "_chongzhi_success";
    public static final String chongzhi_fail = YuEPresenter.class.getName()
            + "_chongzhi_fail";

    /**
     * 交易记录
     */
    public static final String dingdan_success = YuEPresenter.class.getName()
            + "_dingdan_success";
    public static final String dingdan_fail = YuEPresenter.class.getName()
            + "_dingdan_fail";

    /**
     * 提现账号列表
     */
    public static final String ZhangHaoList_success = YuEPresenter.class.getName()+ "_ZhangHaoList_success";
    public static final String ZhangHaoList_fail = YuEPresenter.class.getName()+ "_ZhangHaoList_fail";

    //删除绑定的账号
    public static final String delete_zhanghao_success = YuEPresenter.class.getName()
            + "_delete_zhanghao_success";
    public static final String delete_zhanghao_fail = YuEPresenter.class.getName()
            + "_delete_zhanghao_fail";
    /**
     * 支持账号提现类型
     */
    public static final String BangdingType_success = YuEPresenter.class.getName()+ "_BangdingType_success";
    public static final String BangdingType_fail = YuEPresenter.class.getName()+ "_BangdingType_fail";

    /**
     * 绑定提现账户
     */
    public static final String BANG_success = YuEPresenter.class.getName()+ "_BANG_success";
    public static final String BANG_fail = YuEPresenter.class.getName()+ "_BANG_fail";

    /**
     * 提现申请
     */
    public static final String Tixian_success = YuEPresenter.class.getName()
            + "_Tixian_success";
    public static final String Tixian_fail = YuEPresenter.class.getName()
            + "_Tixian_fail";

    public YuEPresenter(Observer observer) {
        super(observer);
    }

    /**
     * 设置支付密码
     */
    @Override
    public void OnSetUpZhiFuPass(String uid, String old, String news) {
        YuEInterfaces<String> user = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(zhifu_pass_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(zhifu_pass_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        user.OnSetUpZhiFuPass(uid, old, news);
    }
    /**
     * 验证支付密码
     */
    @Override
    public void onZhiFuPassYanZheng(String uid, String secret) {
        YuEInterfaces<String> user = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(yanzheng_pass_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(yanzheng_pass_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        user.onZhiFuPassYanZheng(uid,secret);
    }

    /**
     * 账户余额
     * @param uid
     */
    @Override
    public void onMoney(String uid) {
        YuEInterfaces<String> ShopIngMal=new YuEPresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(Yue_success);
                YuEPresenter.this.setChanged();
                YuEPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(Yue_fail);
                YuEPresenter.this.setChanged();
                YuEPresenter.this.notifyObservers(result);

            }
        });
        ShopIngMal.onMoney(uid);
    }
    @Override
    public void onZhangDan(String uid, String current_page, String per_page) {
        YuEInterfaces<String> user = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(dingdan_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(dingdan_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        user.onZhangDan(uid, current_page,per_page);
    }

    @Override
    public void chongZhi(String uid, String money) {
        YuEInterfaces<String> dingdan = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(chongzhi_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(chongzhi_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        dingdan.chongZhi(uid,money);
    }
    /**
     * 提现账号列表
     * @param uid
     */
    @Override
    public void onZhangHaoList(String uid) {
        YuEInterfaces<String> dingdan = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(ZhangHaoList_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(ZhangHaoList_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        dingdan.onZhangHaoList(uid);
    }
    @Override
    public void deleteZhangHao(String uid, String id) {
        YuEInterfaces<String> dingdan = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(delete_zhanghao_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(delete_zhanghao_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        dingdan.deleteZhangHao(uid,id);
    }
    @Override
    public void onBangDinType() {
        YuEInterfaces<String> dingdan = new YuEPresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(BangdingType_success);
                YuEPresenter.this.setChanged();
                YuEPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(BangdingType_fail);
                YuEPresenter.this.setChanged();
                YuEPresenter.this.notifyObservers(result);

            }
        });
        dingdan.onBangDinType();
    }
    @Override
    public void onByWalletBind(String uid, String account, String account_type,String open_bank) {
        YuEInterfaces<String> dingdan = new YuEPresponsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(BANG_success);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(BANG_fail);
                        YuEPresenter.this.setChanged();
                        YuEPresenter.this.notifyObservers(result);

                    }
                });
        dingdan.onByWalletBind(uid, account,account_type,open_bank);
    }
    @Override
    public void onMoneySys(String uid, String account_id, String money) {
        YuEInterfaces<String> dingdan = new YuEPresponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(Tixian_success);
                YuEPresenter.this.setChanged();
                YuEPresenter.this.notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(Tixian_fail);
                YuEPresenter.this.setChanged();
                YuEPresenter.this.notifyObservers(result);

            }
        });
        dingdan.onMoneySys(uid,account_id,money);
    }
}
